#ifndef ENTITY_H_
#define ENTITY_H_

#include "Object.h"
#include "ObjModel.h"
#include "irrlicht.h"
#include <boost/shared_ptr.hpp>

// Facilitate the use of boost shared_ptr
using namespace boost;

// Facets namespace for the game
namespace Facets
{

	/**
	 * Entity is a class designed to represent an object that is capable of hosting
	 * collision detection as part of its functionality. This prevents certain objects, such as
	 * static terrain, from requiring the overhead of holding a shared_ptr for a camera
	 * that may never be used. It will also remove overhead of any future changes including
	 * the storing of quaternions for the cameras, or a future camera encapsulation class.
	 */
	class Entity : public virtual Facets::Object {
		protected:

			ObjModel* m_Model;
			
			float m_Weight;
			
			core::stringw m_Name;
			
			/**
			 * Function that will handle focusing the current camera.
			 * @return True if camera was focused on entity, false if not.
			 */
			bool FocusCamera();
			
		public:

			void loadModel(const core::stringc& xml) {
				m_Model = new ObjModel(xml);
				m_Model->setPosition(m_Position);
				m_Model->setDirection(m_Direction);
//				m_Model->addNameTag(m_Name);
			}

			/**
			 * @name Constructors
			 * [ Entity constructors, same parameters as the parent class Object. ]
			 */ 
			//@{
			/**
			 * @param pos Position of the object.
			 * @param dir Direction of the object.
			 */
			Entity(const core::vector3df& pos, const core::vector3df& dir);
			/**
			 * @param pos Position of the object.
			 * @param dir Direction of the object.
			 * @param ms Land movement speed.
			 */
			Entity(const core::vector3df& pos, const core::vector3df& dir, s32 ms);
			/**
			 * @param pos Position of the object.
			 * @param dir Direction of the object.
			 * @param ms Land movement speed.
			 * @param as Air movement speed.
			 * @param ss Swimming movement speed.
			 */
			Entity(const core::vector3df& pos, const core::vector3df& dir, s32 ms, s32 as, s32 ss);
			//@}	

			/**
			 * Sets animation if the model is md2. Will add type-checking
			 * later.
			 */ 
			inline void setAnimation(scene::EMD2_ANIMATION_TYPE animtype) {
				m_Model->setAnimation(animtype);
			}

			virtual void update(float dt) {
				m_Position = m_Model->getPosition();
				m_Direction = m_Model->getDirection();
				Object::update(dt);
				m_Model->update();
//				m_Model->setPosition(m_Position);
			}
			
			virtual void setPosition(const core::vector3df& pos);
			virtual void setDirection(const core::vector3df& dir);
			
			void setWeight(const float& weight) {
				m_Weight = weight;
				m_Model->updateWeight(m_Weight);
			}

			irr::scene::ISceneNode* getNode() {
				return m_Model->getNode();
			}
			
			/// Destructs the Entity class and releases the camera.
			virtual ~Entity();	
	};

}

#endif /*ENTITY_H_*/
